/////////////////////////////////////////////////////////////////////////////
// Name:        PackagesListCtrl.h
// Purpose:
// Author:      yospaly
// Modified by:
// Created:     11/12/2008 21:42:32
// RCS-ID:
// Copyright:   Copyright (C) 2008, yospaly
// Licence:
/////////////////////////////////////////////////////////////////////////////

#ifndef _PACKAGESLISTCTRL_H_
#define _PACKAGESLISTCTRL_H_


/*!
 * Includes
 */

////@begin includes
#include "wx/listctrl.h"
////@end includes
#include "common.h"
#include "inibuilder.h"

/*!
 * Forward declarations
 */

////@begin forward declarations
class PackagesListCtrl;
////@end forward declarations

/*!
 * Control identifiers
 */

////@begin control identifiers
#define ID_PACKAGES_LISTCTRL 10013
#define SYMBOL_PACKAGESLISTCTRL_STYLE wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_HRULES|wxLC_VRULES
#define SYMBOL_PACKAGESLISTCTRL_IDNAME ID_PACKAGES_LISTCTRL
#define SYMBOL_PACKAGESLISTCTRL_SIZE wxSize(100, 100)
#define SYMBOL_PACKAGESLISTCTRL_POSITION wxDefaultPosition
////@end control identifiers


/*!
 * PackagesListCtrl class declaration
 */

class PackagesListCtrl: public wxListCtrl
{
    DECLARE_DYNAMIC_CLASS( PackagesListCtrl )
    DECLARE_EVENT_TABLE()

public:
    /// Constructors
    PackagesListCtrl();
    PackagesListCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxLC_ICON, const wxValidator& validator = wxDefaultValidator);

    /// Creation
    bool Create(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxLC_ICON, const wxValidator& validator = wxDefaultValidator);

    /// Destructor
    ~PackagesListCtrl();

    /// Initialises member variables
    void Init();

    /// Creates the controls and sizers
    void CreateControls();

////@begin PackagesListCtrl event handler declarations

    /// wxEVT_COMMAND_LIST_ITEM_SELECTED event handler for ID_PACKAGES_LISTCTRL
    void OnSelected( wxListEvent& event );

    /// wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK event handler for ID_PACKAGES_LISTCTRL
    void OnRightClick( wxListEvent& event );

////@end PackagesListCtrl event handler declarations

////@begin PackagesListCtrl member function declarations

////@end PackagesListCtrl member function declarations

////@begin PackagesListCtrl member variables
////@end PackagesListCtrl member variables
public:
	void OnPkgFilter(wxCommandEvent &event);
	void OnPkgSrcFilter(wxCommandEvent &event);
	
	void OnUnmarkMenuClick(wxCommandEvent &event);
	void OnInstallMenuClick(wxCommandEvent &event);
	void OnReinstallMenuClick(wxCommandEvent &event);
	void OnUpgradeMenuClick(wxCommandEvent &event);
	void OnRemoveMenuClick(wxCommandEvent &event);
	
	void ShowPkgs(const wxString& cat, bool show_source=false);
	
	bool reload();
	
protected:	
	wxImageList* p_img_list;
	wxString _pkgname;
	wxString _cat;
	
	IntegerHash _mark4hash;
	
	bool _mark_for(const wxString& pkg, PkgInfo::STATUS status);
	bool _unmark(const wxString& pkg);
	

	bool _refresh();
};

#endif
    // _PACKAGESLISTCTRL_H_
